package com.ldc.common.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.ldc.common.ApplicationBase;

public class SPUtils {

    private static final String SP_NAME = "Ldc";
    private SharedPreferences sp;
    private SharedPreferences.Editor editor;

    private static class Holder {
        private static final SPUtils INSTANCE = new SPUtils();
    }

    private SPUtils() {
        sp = ApplicationBase.getApplication().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
        editor = sp.edit();
    }


    public void putString(String key, String value) {
        editor.putString(key, value).apply();
    }


    public String getString(String key) {
        return sp.getString(key, "");
    }


    public void remove(String key) {
        editor.remove(key);
    }

    public static SPUtils getInstance() {
        return Holder.INSTANCE;
    }

}
